<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Promise单一状态和状态中转</title>
</head>
<body>
    <script>
        let p1 = new Promise((resolve,reject) => {
            setTimeout(() => {
                reject("失败");
            },2000);
            // promise的状态是单一的，不可逆的，如果执先行了成功，后面就算有执行失败的语句，也不会走失败的语句
            // resolve("成功");
        });

        new Promise((resolve,reject) => {
            // 如果p1这个promise是成功，下面也走成功；如果p1这个promise是失败，下面也走失败
            resolve(p1);
        }).then(
            value => {
                console.log("success" + value);
            },
            reason => {
                console.log("error" + reason);
            }
        )
    </script>
</body>
</html>